<template>
  <div class="equipment_item">
    <div class="col">
      <div class="">
        <p class="item">
          <span class="name ellipsis item_black"> {{ data.deviceName || '-' }}</span>
          <span class="name ellipsis">( {{ data.name || '-' }})</span>
        </p>
        <p class="item date">结束日期:{{ data.endTime || '-' }}</p>
      </div>
    </div>
    <div class="col col_state">
      <p
        class="item"
        :style="{ color: data.hasExecute ? '#009c35' : '#ed6a0c', 'text-align': 'center' }"
      >
        {{ data.hasExecute ? '已完成' : '待执行' }}
      </p>
      <p
        class="item item_state"
        :class="data.hasExecute && 'item_state_undo'"
        @click.stop="doPlan(data)"
      >
        去完成
      </p>
    </div>
  </div>
</template>

<script setup>
const props = defineProps({
  icon: {
    type: String,
    required: '',
  },
  data: {
    type: Object,
    default: () => {
      return {};
    },
  },
});
// 定义 emits
const emit = defineEmits(['doPlan']);

function doPlan(data) {
  if (data.hasExecute) return;
  emit('doPlan', data);
}
</script>

<style lang="scss" scoped>
.equipment_item {
  padding-top: 12px;
  padding-left: 12px;
  display: flex;
  width: 100%;
  justify-content: space-between;
  border-bottom: 1px solid #d9d9d9;
  font-weight: bold;

  .col {
    text-align: center;
  }
  .col_state {
    margin-right: 20px;
  }

  .item {
    height: 40px;
    line-height: 40px;
    font-weight: 400;
    font-size: 13px;
    color: #666666;
    text-align: left;
  }
  .date {
    text-align: left;
  }

  .item_black {
    color: #333333;
    font-size: 14px;
  }

  .item_state {
    display: inline-block;
    color: #ffffff;
    text-align: center;
    border-radius: 21px;
    background-color: #0a92fe;
    width: 74px;
    height: 26px;
    line-height: 26px;
  }
  .item_state_undo {
    background-color: #d7d7d7;
    // color: #ed6a0c;
  }
  .item_state_done {
    background-color: rgba(10, 146, 254, 0.1);
    // color: #009c35;
  }

  .name {
    width: 30%;
    margin-right: 10px;
  }
}
</style>
